﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CO2FixCalibration
{
    class GetHarvestYears
    {
        public static bool GetYears(DataSet CurrentMeasurements, DataSet ControlSimulation, int HarvestCycle, ref int[] harvestyears)
        {
            List<int> HarvestYears = new List<int>();
            if (CurrentMeasurements.Label.Contains("Control"))
            {
                harvestyears = HarvestYears.ToArray();
                return true;
            }  
            // before harvest biomass
            double biom = CurrentMeasurements.GetValueAtTime(CurrentMeasurements.FirstTime);
            for (int t = ControlSimulation.FirstTime; t < ControlSimulation.LastTime; t++)
            {
                if (ControlSimulation.GetValueAtTime(t) > biom)
                {
                    for (int i = 0; i < 20; i++)
                    {
                        HarvestYears.Add(t - ControlSimulation.FirstTime  + i * HarvestCycle);
                    }
                    harvestyears = HarvestYears.ToArray();
                    return harvestyears.Length > 0;
               }
            }
             
            harvestyears = HarvestYears.ToArray();
            return harvestyears.Length > 0;
        }
    }
}
